/*!
\copyright  Copyright (c) 2023 Qualcomm Technologies International, Ltd.\n
            All Rights Reserved.\n
            Qualcomm Technologies International, Ltd. Confidential and Proprietary.
\file
\brief      Header file for creating descriptors for USB Audio class 2.0
*/

#ifndef USB_AUDIO_CLASS_20_DESCRIPTORS_H_
#define USB_AUDIO_CLASS_20_DESCRIPTORS_H_

#include "usb_audio_defines.h"
#include "usb_audio_class_defines.h"
#include "usb_audio_class_20.h"

#define UAC_FN_PROTOCOL_VERSION_02_00  0x20

typedef enum
{
    UAC2_CS_TYPE_EXTERNAL      = 0,
    UAC2_CS_TYPE_FIXED         = 1,
    UAC2_CS_TYPE_VARIABLE      = 2,
    UAC2_CS_TYPE_PROGRAMMABLE  = 3,
    UAC2_CS_TYPE_SOF_SYNC      = (1 << 2)
} uac2_clock_source_type_t;

typedef enum
{
    UAC2_CS_CONTROL_FREQUENCY_READ = (1 << 0),
    UAC2_CS_CONTROL_FREQUENCY      = (3 << 0),
    UAC2_CS_CONTROL_VALIDITY_READ  = (1 << 2),
    UAC2_CS_CONTROL_VALIDITY       = (3 << 2),
} uac2_clock_source_control_support_t;

/** A.17.1 Clock Source Control Selectors */
typedef enum
{
    UAC2_CS_CONTROL_UNDEFINED = 0x00,
    UAC2_CS_SAM_FREQ_CONTROL = 0x01,
    UAC2_CS_CLOCK_VALID_CONTROL = 0x02
} uac2_clock_source_control_t;

/** A.7 Audio Function Category Codes */
typedef enum
{
    UAC2_FUNCTION_SUBCLASS_UNDEFINED = 0x00,
    UAC2_DESKTOP_SPEAKER = 0x01,
    UAC2_HOME_THEATER = 0x02,
    UAC2_MICROPHONE = 0x03,
    UAC2_HEADSET = 0x04,
    UAC2_TELEPHONE = 0x05,
    UAC2_CONVERTER = 0x06,
    UAC2_VOICE_SOUND_RECORDER = 0x07,
    UAC2_I_O_BOX = 0x08,
    UAC2_MUSICAL_INSTRUMENT = 0x09,
    UAC2_PRO_AUDIO = 0x0A,
    UAC2_AUDIO_VIDEO = 0x0B,
    UAC2_CONTROL_PANEL = 0x0C,
    UAC2_OTHER = 0xFF
} uac2_function_category_t;

/** A.17.2 Clock Selector Control Selectors */
typedef enum
{
    UAC2_CX_CONTROL_UNDEFINED = 0x00,
    UAC2_CX_CLOCK_SELECTOR_CONTROL = 0x01
} uac2_clock_source_selector_t;

/*! Clock Source Descriptor length */
#define UAC2_CS_DESC_SIZE 8

/*! Input Terminal Descriptor length */
#define UAC2_IT_DESC_SIZE 17

/*! To get Feature Unit Descriptor length from channel count and control size */
#define UAC2_FU_DESC_SIZE(num_channels) (6+((num_channels)+1)*4)

/*! Output Terminal Descriptor length*/
#define UAC2_OT_DESC_SIZE 12

/*! Class-Specific AS Interface Descriptor length */
#define UAC2_AS_IF_DESC_SIZE 16

/*! To get Class-Specific AC Interface Header Descriptor length from interface count */
#define UAC2_AC_IF_HEADER_DESC_SIZE 9

/*! Type I Format Type Descriptor length */
#define UAC2_FORMAT_1_DESC_SIZE 6

/*! Class-Specific AS Isochronous Audio Data Endpoint Descriptor length */
#define UAC2_AS_DATA_EP_DESC_SIZE  8

#endif /* USB_AUDIO_CLASS_20_DESCRIPTORS_H_ */

